<?
	session_start();
	require("checksessionadmin.php");
	require("connect.php");
	if ($_REQUEST["option"]==Xoa)
	mysql_query("delete from baiviet where mabv='{$_REQUEST["mabv"]}'");	
 	$chon2=$_REQUEST["option2"];
 	switch ($chon2){		
		case "chapnhan":
			mysql_query("update binhluanbaiviet set trangthai='1' where mabl={$_REQUEST["mabl"]}") or die("Kiểm tra lại !");
			break;		
		case "xoa":				
			mysql_query("delete from binhluanbaiviet where mabl='{$_REQUEST["mabl"]}'");			
			break;
	}	
?>
<html><!-- InstanceBegin template="/Templates/admintemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="../scripts/innovaeditor.js"></script>
<link rel="stylesheet" type="text/css" href="../css/engine.css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script language="javascript" type="text/javascript" src="../js/datetimepicker.js">
</script>
</head>
<body>
<table align="center" width="960px" cellpadding="0" cellspacing="0" border="0">
<tr><td colspan="2" height="124" valign="top" align="center">
	<object classid="clsidsmilie27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="960" height="124" align="absmiddle">
   <param name="movie" value="flash/banneradmin.swf" />
   <param name="quality" value="high" />
   <embed src="../flash/banneradmin.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="960" height="124" align="absmiddle"></embed>
 	</object>
</td></tr>
<tr><td colspan="2" height="34">	
	<div id="menuadmin">
		<ul id="p7menubar">
			 <li><a class="trigger" href="index.php" target="_self">Trang chủ admin</a></li>
			 <li class="linemenus"></li>					 
		 	 <li><a class="trigger" href="../index.php" target="_self">Trang chủ trường</a>									  	
		  	<li class="linemenus"></li>					 
		  	<li><a class="trigger" href="thongtincanhanadmin.php" target="_self">Thông tin cá nhân</a>			
			<li class="linemenus"></li>					 
		  	<li><a class="trigger" href="../logout.php" target="_self">Thoát</a>	
			<li class="linemenus"></li>	
			<li><a class="trigger">							
				<?
				$nguoidung=$_SESSION["username"];
				if($_SESSION["quyen"]==0){
				$resu23=mysql_query("select * from admin where maadmin='{$nguoidung}'");
				$row23=mysql_fetch_array($resu23);
				?>
					<font color="#FFFFFF">			 
					<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
					</font>
				<? }?>	
			</a>							
		  <!--het-->
		</ul>
	</div>	
	</td>
</tr>
<tr>
<td valign="top" align="left" height="750" width="180">
	<!--menu trai-->
		<table align="center" width="100%" border="1" cellpadding="0" cellspacing="0">
		<tr><td valign="middle" height="30">
			<a href="tintuc_admin.php"><img src="../anh/tintuc.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tintuc_admin.php">Quản lý tin tức</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="loaitin_admin.php"><img src="../anh/loaitin.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="loaitin_admin.php">Quản lý loại tin</a>
		</td></tr>		
		<tr><td valign="middle" height="30">
				<a href="lopctn_admin.php"><img src="../anh/lopctn.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="lopctn_admin.php">Quản lý lớp</a>
		</td></tr>
		
		<tr><td valign="middle" height="30">
			<a href="tobomon_admin.php"><img src="../anh/tobomon.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tobomon_admin.php">Quản lý tổ giáo viên</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="giaovien_admin.php"><img src="../anh/giaovien.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="giaovien_admin.php">Quản lý giáo viên</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="phuhuynh_admin.php"><img src="../anh/phuhuynh.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="phuhuynh_admin.php">Quản lý phụ huynh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="hocsinh_admin_1.php"><img src="../anh/user.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="hocsinh_admin_1.php">Quản lý học sinh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thoikhoabieu_admin.php"><img src="../anh/thoikhoabieu.png" height="16" width="15" border="0">&nbsp;&nbsp;</a><a href="thoikhoabieu_admin.php">Quản lý thời khóa biểu</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="baiviet_admin.php"><img src="../anh/baiviet.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="baiviet_admin.php">Quản lý bài viết</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="monhoc_admin.php"><img src="../anh/monhoc.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="monhoc_admin.php">Quản lý môn học</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="tailieu_admin.php"><img src="../anh/tailieu.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tailieu_admin.php">Quản lý tài liệu</a>
		</td></tr>
		<?
			$menu=$_REQUEST["opt"];
			if(($menu=="")||($menu==ko)){
		?>
			<tr><td valign="middle" height="30">
				<a href="?opt=co"><img src="../anh/thuvienanh.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="?opt=co">Quản lý thư viện ảnh</a>
			</td></tr>
		<? }else if($menu==co){?>
			<tr><td valign="middle" height="30">
				<a href="?opt=ko"><img src="../anh/thuvienanh.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="?opt=ko">Quản lý thư viện ảnh</a><br>
				&nbsp;<a href="thuvienanh_admin.php">
					<img src="../anh/1px.gif" height="15" width="16" border="0">
				</a><a href="thuvienanh_admin.php">Thư viện ảnh trường</a><br>
				&nbsp;<a href="thuvienanhlop_admin.php">
					<img src="../anh/1px.gif" height="15" width="16" border="0">
				</a><a href="thuvienanhlop_admin.php">Thư viện ảnh lớp</a>
			</td></tr>
		<? }?>
		
		<tr><td valign="middle" height="30">
			<a href="khoahoc_admin.php"><img src="../anh/khoahoc.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="khoahoc_admin.php">Quản lý khóa học</a>
		</td></tr>
		<!--
		<tr><td valign="middle" height="30">
			<a href="admin_admin.php"><img src="../anh/admin.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="admin_admin.php">Quản lý account</a>
		</td></tr>	
		-->
		<tr><td valign="middle" height="30">
			<a href="admin_sodaubai.php"><img src="../anh/sodaubai.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="sodaubai_admin.php">Quản lý sổ ghi đầu bài</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="admin_lienket.php"><img src="../anh/lienket.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="lienket_admin.php">Quản lý menu</a>
		</td></tr>		
		</table>
</td>
<!--Het menu trai-->
    <td valign="top" align="center"><!-- InstanceBeginEditable name="EditRegion3" -->
	<?
		
	?>
	<h3 align="center"><font color="#CC3333">Quản lý bài viết</font> </h3>		
	<div class="paneladmin">
			<div class="paneladmin_header"><font color="#003366">BÀI VIẾT MỚI CHƯA XỬ LÝ</font></div>
			<table align="center" cellpadding="3" cellspacing="0" border="0" width="99%">
				<?	
					$result=mysql_query("select * from baiviet where trangthai='0' order by ngay DESC");
					if(mysql_num_rows($result)<=0){		
						echo "Không có bài viết nào !";
					}else{
							$num_page=ceil(mysql_num_rows($result)/10);
							$page = $_REQUEST["page"];
							if($page <= 0) $page = 1;
							if($page > $num_page) $page = $num_page;
							$a = ($page - 1)*10;
							$result2 = mysql_query("select * from baiviet where trangthai='0' order by ngay DESC limit {$a},10");
							while($r2=mysql_fetch_array($result2)){																																									
				?>
											<tr><td>							
												<a href="baiviet_admin_detail.php?mabv=<? echo $r2["mabv"];?>">
												<img src="../anh/icon1.gif" width="16" height="16" border="0">&nbsp;
												<?										
														$string=$r2["tieude"];
														echo substr($string,0,70);
														if(strlen($string)>=71){
														echo "...";						
														}				
												?>
												</a>
											</td></tr>																
											<tr>
												<td class="tieude3">  bởi 																		
													<?
														$result31=mysql_query("select * from hocsinh where mahs='{$r2["nguoidang"]}'");
														if(mysql_num_rows($result31)>0){
														while($r31=mysql_fetch_array($result31)){
														?>
															<a href="hocsinh_admin_detail.php?mahs=<? echo $r2["nguoidang"];?>" title="Thông tin học sinh">																								
														<?
															echo $r31["hotendem"];
															echo "&nbsp;";
															echo $r31["ten"];
														?></a><?
														}}else {
															$result21=mysql_query("select * from giaovien where magv='{$r2["nguoidang"]}'"); 
															$r21=mysql_fetch_array($result21);
															echo "giáo viên";
															echo "&nbsp;";
															?>
															<a href="giaovien_admin_detail.php?mahs=<? echo $r2["nguoidang"];?>" title="Thông tin giáo viên">																								
															<?																														
															echo $r21["hotendem"];
															echo "&nbsp;";
															echo $r21["ten"];
															?>
															<?
															
														}
													?>
												&nbsp;lớp <?
												$result5=mysql_query("select * from lop where mal='{$r2["mal"]}'");
												$r5=mysql_fetch_array($result5);												
												echo $r5["tenl"];
												?>																							
												&nbsp;vào lúc &nbsp;<? echo $r2["ngay"];?>
												&nbsp;thuộc <?
												$result4=mysql_query("select * from loaibaiviet where malbv='{$r2["malbv"]}'");
												$r4=mysql_fetch_array($result4);
												?>
												<a href="loaibaiviet_admin_detail.php?malbv=<? echo $r2["malbv"];?>"><?
												echo $r4["tenlbv"];
												?></a>
												</td>										
											</tr>
											<tr>
												<td class="tieude3">
													<a href="baiviet_admin_detail.php?mabv=<? echo $r2["mabv"];?>" title="Xem chi tiết">
													<img src="../anh/chitiet.png" height="16" width="16" border="0">&nbsp;Chi tiết
													</a>&nbsp;
													<a href="?mabv=<? echo $r2["mabv"];?>&option=Xoa" title="Xóa bài viết" onClick="return confirm('Bạn có chắc muốn xóa không ?');">
													<img src="../anh/xoa.png" height="16" width="16" border="0">&nbsp;Xóa
													</a>													
												</td>
											</tr>
											<tr><td><div class="noidungnhanxet"></div></td></tr>									
						<? 
										} //end of while(r2)							  																							
						?>
						<tr><td>
						<strong>
						<? 
							for($i = 1; $i <=$num_page; $i++)
							if ($i==$page)  echo "&nbsp;Trang&nbsp;".$i."&nbsp;";
							else echo "&nbsp;<a href=?page={$i}>&nbsp;Trang&nbsp;{$i}</a>&nbsp;";
						?>	
						</strong>	
						</td></tr>
					<?
						} //end of if(r2>0)		
					?> 																			
			</table>					
	</div>
	<!--Begin buoi chieu-->
	<div class="paneladmin">
			<div class="paneladmin_header"><font color="#003366">BÌNH LUẬN BÀI VIẾT CHƯA XỬ LÝ</font></div>
			<table align="center" cellpadding="3" cellspacing="0" border="0" width="99%">				
						<?	
						$result5=mysql_query("select * from binhluanbaiviet where trangthai='0' order by thoigian DESC");
							if(mysql_num_rows($result5)<=0){		
								echo "Không có bình luận bài viết nào !";
							}else{
								$num_page2=ceil(mysql_num_rows($result5)/20);
								$page2 = $_REQUEST["page2"];
								if($page2 <= 0) $page2 = 1;
								if($pag2e > $num_page2) $page2 = $num_page2;
								$a2 = ($page2 - 1)*20;								
								$result6=mysql_query("select * from binhluanbaiviet where trangthai='0' order by thoigian DESC limit {$a2},20");									
								while($r6=mysql_fetch_array($result6)) {
									?>
										<tr><td>
											<img src="../anh/comment.png" height="16" width="16" border="0">&nbsp;											
											<?
														$result7=mysql_query("select * from hocsinh where mahs='{$r6["nguoidang"]}'");
														if(mysql_num_rows($result7)>0){
														$r7=mysql_fetch_array($result7);
															?>
																<a href="hocsinh_admin_detail.php?mahs=<? echo $r6["nguoidang"];?>" title="Thông tin học sinh">																								
															<?
																echo $r7["hotendem"];
																echo "&nbsp;";
																echo $r7["ten"];
															?></a><?
														}else {
															$result8=mysql_query("select * from giaovien where magv='{$r6["nguoidang"]}'"); 
															$r8=mysql_fetch_array($result8);
															echo "Giáo viên";
															echo "&nbsp;";
															?>
															<a href="giaovien_admin_detail.php?magv=<? echo $r6["nguoidang"];?>" title="Thông tin giáo viên">
																<?
																echo $r8["hotendem"];
																echo "&nbsp;";
																echo $r8["ten"];
																?>
															</a>
															<?
															
														}
											?>																								
											vào lúc <? echo $r6["thoigian"];?>&nbsp;
											<a href="?option2=chapnhan&mabl=<? echo $r6["mabl"]?>&magv=<? echo $magv;?>"  onClick="return confirm('Bạn chấp nhận bình luận này ?');">
												<img src="../anh/accept.png" height="16" width="16" border="0">&nbsp;Chấp nhận
											</a>&nbsp;
											<a href="?option2=xoa&mabl=<? echo $r6["mabl"]?>&magv=<? echo $magv;?>" onClick="return confirm('Bạn có chắc muốn xóa không ?');">
												<img src="../anh/xoa.png" height="16" width="16" border="0">&nbsp;Xóa
											</a>
										</td></tr>
										<tr><td class="tieude3">của bài viết 
											<a href="baiviet_admin_detail.php?mabv=<? echo $r6["mabv"];?>" title="Chi tiết bài viết">
											<?
												$result9=mysql_query("select * from baiviet where mabv='{$r6["mabv"]}'");
												$r9=mysql_fetch_array($result9);
												echo $r9["tieude"];
											?>
											</a>
										</td></tr>
										<tr><td>&nbsp;&nbsp;<? echo $r6["noidung"];?></td></tr>
										<tr><td><div class="noidungnhanxet"></div></td></tr>	
							<? }?>
										<tr><td>
											<strong>
											<? 
												for($i2 = 1; $i2 <=$num_page2; $i2++)
												if ($i2==$page2)  echo "&nbsp;Trang&nbsp;".$i2."&nbsp;";
												else echo "&nbsp;<a href=?page={$i}>&nbsp;Trang&nbsp;{$i2}</a>&nbsp;";
											?>	
											</strong>	
										</td></tr>
										<? }?>
			</table>			
	</div>
	<!--End buoi chieu-->
	  		
<!-- InstanceEndEditable --></td>
</tr>
<tr><td colspan="2" height="100" valign="middle" align="center" bgcolor="#999999">Phạm Đức Đóa - Khoa CNTT - Đại học Xây Dựng</td></tr>
</table>
</body>
<!-- InstanceEnd --></html>
